package org.example.aitest.dto;

import lombok.Data;

import java.util.Objects;

@Data
public class TableColumn {
    private String name;
    private String type;  // 如 VARCHAR, INT, DATETIME 等
    private int length;   // 字段长度，如 VARCHAR(100) 中的 100
    private Boolean nullable = true; //是否允许空，默认允许
    private String comment; //字段注释
    private Boolean only = false; //是否唯一，用于表直接关联

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TableColumn that = (TableColumn) o;
        return name.equalsIgnoreCase(that.name); // 仅比较 name，忽略大小写
    }

    @Override
    public int hashCode() {
        return Objects.hash(name.toLowerCase()); // 统一转为小写计算 hashCode
    }
}
